Skip to content

Conversation

@corylanou
Copy link
Collaborator

Summary

  • Add native support for Alibaba Cloud Object Storage Service (OSS) as a replication backend
  • Uses official alibabacloud-oss-go-sdk-v2 SDK instead of S3-compatible mode
  • Includes multipart upload support for large files (>5GB) with configurable part-size/concurrency
  • Preserves timestamps via OSS metadata for accurate point-in-time recovery

Background

Litestream 0.5+ uses AWS SDK Go v2, which enables chunked encoding for uploads ≥5MB. Alibaba Cloud OSS doesn't support chunked encoding via its S3-compatible mode, breaking OSS users who upgraded from 0.3.x.

Changes

New Files

  • oss/replica_client.go - Main OSS ReplicaClient implementation
  • oss/replica_client_test.go - Unit tests

Modified Files

  • cmd/litestream/main.go - Add OSS config parsing and registration
  • cmd/litestream/replicate.go - Add OSS logging
  • internal/testingutil/testingutil.go - Add OSS integration test support
  • go.mod, go.sum - Add Alibaba SDK dependency
  • CLAUDE.md, AGENTS.md, docs/ARCHITECTURE.md - Documentation updates

Configuration

# Explicit configuration
dbs:
  - path: /data/mydb.sqlite
    replicas:
      - type: oss
        bucket: my-bucket
        region: cn-hangzhou
        part-size: 10485760   # Optional: 10MB parts
        concurrency: 5        # Optional: parallel uploads

# URL format
dbs:
  - path: /data/mydb.sqlite
    replicas:
      - url: oss://my-bucket.oss-cn-hangzhou.aliyuncs.com/backups

Environment Variables

Variable Description
LITESTREAM_OSS_ACCESS_KEY_ID Alibaba Cloud access key ID
LITESTREAM_OSS_ACCESS_KEY_SECRET Alibaba Cloud access key secret
LITESTREAM_OSS_REGION OSS region (e.g., cn-hangzhou)
LITESTREAM_OSS_BUCKET OSS bucket name

Test plan

  • Unit tests pass (go test -v ./oss/...)
  • Build passes (go build ./...)
  • Linters pass (go vet, staticcheck)
  • Pre-commit hooks pass
  • Integration tests with real OSS bucket (requires credentials)

Closes #861

🤖 Generated with Claude Code

Add native support for Alibaba Cloud Object Storage Service (OSS) as a
replication backend. This addresses issue #861 where Litestream 0.5+
uses AWS SDK Go v2 with chunked encoding, which OSS doesn't support
via S3-compatible mode.

Features:
- Native OSS SDK integration (alibabacloud-oss-go-sdk-v2)
- Multipart upload support for large files (>5GB) with configurable
  part-size and concurrency settings
- Timestamp preservation via OSS metadata for point-in-time recovery
- Support for both URL and explicit configuration
- Integration test support with LITESTREAM_OSS_* environment variables

Configuration examples:
  replicas:
    - type: oss
      bucket: my-bucket
      region: cn-hangzhou

  replicas:
    - url: oss://my-bucket.oss-cn-hangzhou.aliyuncs.com/backups

Closes #861

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add native Alibaba Cloud OSS storage backend support

2 participants